package com;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.StandardCharsets;

public class TestMockMain {
   public static void main(String[] args) throws Exception {
      System.out.println("Hello World "+StandardCharsets.UTF_8.displayName());
      System.out.println("Hello World "+StandardCharsets.UTF_8.name());
      String filePath ="C:\\Users\\r6yuxx\\Desktop\\TestMockMainTest.java";
      FileChannel channel = new RandomAccessFile(filePath,"r").getChannel();

      CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();

      ByteBuffer buf = ByteBuffer.allocate(1024);
      CharBuffer  charBuf ;
      while(channel.read(buf) != -1) {
         buf.flip();
         charBuf = decoder.decode(buf);
//         while(buf.hasRemaining()) {
//            System.out.print((char)buf.get());
//         }
         System.out.println(charBuf);

         buf.clear();
      }

   }
}
